<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Item - Bottom</title>
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
    />
    <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
  </head>

  <style>
    ion-item.custom {
      --border-width: 5px;
    }
  </style>

  <body>
    <ion-app>
      <ion-header>
        <ion-toolbar>
          <ion-title>Item inputs</ion-title>
        </ion-toolbar>
      </ion-header>

      <ion-content class="ion-padding-vertical">
        <ion-list class="basic">
          <ion-item>
            <ion-label>No Helper/Error</ion-label>
            <ion-input name="input" id="text"></ion-input>
          </ion-item>

          <ion-item>
            <ion-label>Helper and Error</ion-label>
            <ion-input></ion-input>
            <ion-note slot="helper">Helper Text</ion-note>
            <ion-note slot="error">Error Text</ion-note>
          </ion-item>

          <ion-item>
            <ion-label>Helper Only</ion-label>
            <ion-input></ion-input>
            <ion-note slot="helper">Helper Text</ion-note>
          </ion-item>

          <ion-item>
            <ion-label>Error Only</ion-label>
            <ion-input></ion-input>
            <ion-note slot="error">Error Text</ion-note>
          </ion-item>

          <ion-item class="custom">
            <ion-label>Both w/ Custom CSS</ion-label>
            <ion-input></ion-input>
            <ion-note slot="helper">Helper Text</ion-note>
            <ion-note slot="error">Error Text</ion-note>
          </ion-item>
        </ion-list>

        <ion-grid>
          <ion-row>
            <ion-col>
              <ion-item fill="solid">
                <ion-label>Helper and Error (Fill Solid)</ion-label>
                <ion-input></ion-input>
                <ion-note slot="helper">Helper Text</ion-note>
                <ion-note slot="error">Error Text</ion-note>
              </ion-item>
            </ion-col>
            <ion-col>
              <ion-item fill="outline">
                <ion-label>Helper and Error (Fill Outline)</ion-label>
                <ion-input></ion-input>
                <ion-note slot="helper">Helper Text</ion-note>
                <ion-note slot="error">Error Text</ion-note>
              </ion-item>
            </ion-col>
          </ion-row>
          <ion-row>
            <ion-col>
              <ion-item>
                <ion-label>Toggle Error</ion-label>
                <ion-toggle slot="start" id="error-toggle" color="danger"></ion-toggle>
              </ion-item>
            </ion-col>
          </ion-row>
        </ion-grid>
      </ion-content>
    </ion-app>

    <script>
      (function toggleHelperError() {
        const toggle = document.getElementById('error-toggle');
        toggle.addEventListener('ionChange', (ev) => {
          const items = Array.from(document.querySelectorAll('ion-item'));
          items.forEach((item) => item.classList.toggle('ion-invalid'));
        });
      })();
    </script>
  </body>
</html>
